package com.jia.train.seat.controller;

import com.jia.train.global.page.PageResponse;
import com.jia.train.global.response.BaseResponse;
import com.jia.train.seat.request.StationQueryRequest;
import com.jia.train.seat.request.StationSaveRequest;
import com.jia.train.seat.response.StationQueryResponse;
import com.jia.train.seat.response.StationSaveResponse;
import com.jia.train.seat.service.StationService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/station")
public class StationController {

    // 甲午 丙寅 壬戌 庚子 
    @Resource
    private StationService stationService;

    @PostMapping("/insert")
    public BaseResponse<StationSaveResponse> insertStation(@Valid @RequestBody StationSaveRequest request) {
        StationSaveResponse response = stationService.insert(request);
        return new BaseResponse<>(response);
    }

    @GetMapping("/query")
    public BaseResponse<PageResponse<StationQueryResponse>> query(@Valid StationQueryRequest request) {
        PageResponse<StationQueryResponse> responseList = stationService.selectPage(request);
        return new BaseResponse<>(responseList);
    }

    @GetMapping("/list")
    public BaseResponse<List<StationQueryResponse>> list() {
        List<StationQueryResponse> responseList = stationService.selectList();
        return new BaseResponse<>(responseList);
    }

    @DeleteMapping("/delete/{id}")
    public BaseResponse<String> delete(@PathVariable Long id) {
        stationService.deleteStation(id);
        return new BaseResponse<>("success");
    }

}
